﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using So_Tu_Phap;
using System.Data;
using System.Data.OleDb;

namespace So_Tu_Phap
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {

             //   DataTable dbo_DMDanToc = CMSUtils.GetDataSQL("1", "dbo_Goc_Loai", "*", "", "");
                //string[] cols = { "MaLoai","TenLoai" };
                //object[] data = { "1000007","dech" };
                //MessageBox.Show(CMSUtils.InsertDataSQL("dbo_Goc_Loai", cols, data).ToString());
                 //MessageBox.Show(CMSUtils.GetDataSQL("dbo_Goc_Loai", "TenLoai", "TenLoai LIKE 'Câu hỏi thường gặp'", "").ToString());
                //MessageBox.Show(CMSUtils.GetDataSQL("dbo_TB_TaiKhoan", "TenTaiKhoan", "TenTaiKhoan LIKE 'admin'", "").ToString());
                //////========== viết query
                //bool kq = true;
                //try
                //{

                //    object select = "DT.TenDanToc AS DanToc,HS.MaKS,HS.MaKhuVuc, HS.So, HS.QuyenSo, HS.NgayDangKy, HS.HoTen, HS.GioiTinh, HS.NgaySinh,HS.ThangSinh, HS.NamSinh, HS.GioSinh, HS.PhutSinh, HS.NoiSinh,HS.QueQuan,HS.ConThu, HS.HoTenCha, HS.NgaySinhCha, HS.ThangSinhCha, HS.NamSinhCha, HS.TuoiCha, HS.QueQuanCha, HS.DiaChiCha, HS.HoTenMe, HS.NgaySinhMe, HS.ThangSinhMe, HS.NamSinhMe, HS.TuoiMe, HS.QueQuanMe, HS.DiaChiMe, HS.HoTenKhai, HS.NgaySinhKhai,HS.ThangSinhKhai, HS.NamSinhKhai, HS.TuoiKhai, HS.CMNDGTTTKhai, HS.QuanHeKhai, HS.HoTenCBHT, HS.NguoiKy, HS.ChucDanh, HS.ThuongTru,HS.Huy, HS.GhiChu, HS.NguoiCapNhat, HS.NgayCapNhat, HS.CaiChinh, HS.Phuong, HS.Quan, HS.ThanhPho,DTC.TenDanToc AS DanTocCha,DTM.TenDanToc AS DanTocMe,QT.TenQuocTich AS QuocTich,QTC.TenQuocTich AS QuocTichCha,QTM.TenQuocTich AS QuocTichMe,LKS.NoiDung AS LoaiKS,KV.TenKhuVuc";
                //    object from = "(((((((dbo_KhaiSinh HS LEFT OUTER JOIN dbo_DMDanToc DT ON HS.DanToc = DT.MaDanToc)LEFT OUTER JOIN dbo_DMDanToc DTC ON HS.DanTocCha = DTC.MaDanToc)LEFT OUTER JOIN dbo_DMDanToc DTM ON HS.DanTocMe = DTM.MaDanToc)LEFT OUTER JOIN dbo_DMQuocTich QT ON HS.QuocTich = QT.MaQuocTich)LEFT OUTER JOIN dbo_DMQuocTich QTC ON HS.QuocTichCha = QTC.MaQuocTich)LEFT OUTER JOIN dbo_DMQuocTich QTM ON HS.QuocTichMe = QTM.MaQuocTich)LEFT OUTER JOIN dbo_DMLoaiKhaiSinh LKS ON HS.LoaiKS = LKS.LoaiKS)LEFT OUTER JOIN dbo_DMKhuVuc KV ON HS.MaKhuVuc = KV.MaKhuVuc";

                //    string query = "CREATE VIEW dbo_VW_KhaiSinh AS SELECT {0} FROM  {1}";
                //    query = String.Format(query, select.ToString(), from.ToString());

                //    OleDbCommand cmd = new OleDbCommand(query, ConnectToDB.getConnection());
                //    kq = cmd.ExecuteNonQuery() > 0;
                //    MessageBox.Show("ok");
                //}
                //catch (Exception ex)
                //{
                //    kq = false;
                //    MessageBox.Show(ex.ToString());
                //}
                //==================

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new StartupForm());
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
    }
}
